//deleteMSG

if(request.method!=='POST'){

	response.redirect("/home",request,response);
	    response.end();

}else{
   
	var boardName=request.parameters["boardName"];
	var id=request.parameters["id"];

	var session=request.getSession();
		if(typeof session==='undefined'){


		var output = {redirect: "/login",msg:"not good"};
	
		response.headers["Content-Type"]="application/json";	
		response.headers["Access-Control-Allow-Origin"]="*";
		response.body="";
		response.body+=JSON.stringify(output);
		response.end();
	
	}else if(!session.LoggedIn){
		var output = {redirect: "/login",msg:"not good"};
	
		response.headers["Content-Type"]="application/json";	
		response.headers["Access-Control-Allow-Origin"]="*";
		response.body="";
		response.body+=JSON.stringify(output);
		response.end();

	}else{
		var user=session.user;

		//check if user belongs to the board

		var boardController=request.require("./boardController");
		

	var cb1=function (bname,response){

		if(!bname){
			 response.status = 403 ;
	        response.end();
		}else{

		//delete messages from DB for given boardname
		
			var boardController=request.require("./boardController");
			boardController.deleteMessagesfromBoard(bname.board_name,id,response,cb2);
			}
	};


	boardController.getBoardUserPermission(boardName,request.user.username,response,cb1);
	}
}





function cb2(id,response){

	
	
	
		
		var output = {msgId:id};
	
		response.headers["Content-Type"]="application/json";
		response.headers["Access-Control-Allow-Origin"]="*";
		response.body="";
		response.body+=JSON.stringify(output);
		response.end();
		
	
	
	
}



